Imports System.ComponentModel

Public Class RootObjectWrapperBase
	Inherits WrapperBase

	Private m_ChildObjects As New System.Collections.Generic.List(Of IDisposable)
	Protected Friend ReadOnly Property ChildObjects() As System.Collections.Generic.List(Of IDisposable)
		Get
			Return Me.m_ChildObjects
		End Get
	End Property

	<Description("Construcotr.")> _
	Public Sub New(<Description("Native (COM+) object.")> ByVal nativeObject As Object)
		MyBase.New(nativeObject)
	End Sub

	Protected Overrides Sub DisposeInternal()
		'For Each childObject As IDisposable In Me.m_ChildObjects
		'	If childObject IsNot Nothing Then
		'		childObject.Dispose()
		'	End If
		'Next
		For i As Integer = Me.m_ChildObjects.Count - 1 To 0 Step -1
			Dim childObject As IDisposable = Me.m_ChildObjects(i)
			If childObject IsNot Nothing Then
				childObject.Dispose()
			End If
		Next i

		Me.m_ChildObjects.Clear()

		MyBase.DisposeInternal()
	End Sub
End Class
